import { createRouter, createWebHistory } from 'vue-router'
import ImageAnalysis from '../components/pages/ImageAnalysis.vue'
import AngleMeasurement from '../components/pages/AngleMeasurement.vue'
import WeightBearing from '../components/pages/WeightBearing.vue'

const routes = [
  {
    path: '/',
    redirect: '/image-analysis'
  },
  {
    path: '/image-analysis',
    name: 'ImageAnalysis',
    component: ImageAnalysis,
    meta: {
      title: '影像分析',
      icon: 'Picture'
    }
  },
  {
    path: '/angle-measurement',
    name: 'AngleMeasurement',
    component: AngleMeasurement,
    meta: {
      title: '角度测量',
      icon: 'Compass'
    }
  },
  {
    path: '/weight-bearing',
    name: 'WeightBearing',
    component: WeightBearing,
    meta: {
      title: '负重线计算',
      icon: 'Operation'
    }
  },
  // 以下页面暂时注释，将在后续开发中添加
  /*
  {
    path: '/osteotomy-planning',
    name: 'OsteotomyPlanning',
    component: () => import('../components/pages/OsteotomyPlanning.vue'),
    meta: {
      title: '截骨规划',
      icon: 'Tools'
    }
  },
  {
    path: '/hto-planning',
    name: 'HTOPlanning',
    component: () => import('../components/pages/HTOPlanning.vue'),
    meta: {
      title: 'HTO规划',
      icon: 'Tools'
    }
  },
  {
    path: '/dfo-planning',
    name: 'DFOPlanning',
    component: () => import('../components/pages/DFOPlanning.vue'),
    meta: {
      title: 'DFO规划',
      icon: 'Tools'
    }
  },
  {
    path: '/parameter-settings',
    name: 'ParameterSettings',
    component: () => import('../components/pages/ParameterSettings.vue'),
    meta: {
      title: '参数设置',
      icon: 'Setting'
    }
  },
  {
    path: '/simulation',
    name: 'Simulation',
    component: () => import('../components/pages/Simulation.vue'),
    meta: {
      title: '结果模拟',
      icon: 'View'
    }
  },
  {
    path: '/case-management',
    name: 'CaseManagement',
    component: () => import('../components/pages/CaseManagement.vue'),
    meta: {
      title: '病例管理',
      icon: 'FolderOpened'
    }
  },
  {
    path: '/case-list',
    name: 'CaseList',
    component: () => import('../components/pages/CaseList.vue'),
    meta: {
      title: '病例列表',
      icon: 'FolderOpened'
    }
  },
  {
    path: '/report-generation',
    name: 'ReportGeneration',
    component: () => import('../components/pages/ReportGeneration.vue'),
    meta: {
      title: '报告生成',
      icon: 'Document'
    }
  }
  */
]

const router = createRouter({
  history: createWebHistory(),
  routes
})

// 路由守卫
router.beforeEach((to, from, next) => {
  // 设置页面标题
  if (to.meta?.title) {
    document.title = `${to.meta.title} - OsteoMaster`
  }
  next()
})

export default router
